package com.demo.scheduler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ch3nw3i@gitee
 * @package com.demo.scheduler
 * @date 2021-01-10 15:29
 */
@Slf4j
@Component
@Async
public class TestScheduler {

    /**
     * 注解定义调度任务的方法，这个方法会在spring的ioc中被封装成一个Runnable对象，
     * 如果定义了cron表达式则会进入到CronTask的Runnable中
     *
     */
    @Scheduled(cron = "0/3 * * * * *")
    public void test() {
        log.info("执行定时任务test1");
    }

    @Scheduled(cron = "0/6 * * * * *")
    public void test2() {
        log.info("执行定时任务test2");
    }
}
